﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BookReader
{
    class uCommand:ICommand
    {
        #region ICommand 成员

        void ICommand.Execute(string[] param)
        {
            if (String.IsNullOrEmpty(StaticData.openBookString))
            {
                Console.WriteLine("没有打开的文件");
            }
            StaticData.PageIndex--;
            if (StaticData.PageIndex > -1 && StaticData.PageIndex < StaticData.PageCount)
            {
                int start = StaticData.PageIndex * StaticData.pageSize;
                for (int i = start, lc = 0; lc < StaticData.pageSize; i++, lc++)
                {
                    if (i < StaticData.lines.Count)
                    {
                        Console.WriteLine(StaticData.lines[i]);
                        StaticData.currentIndex = i;
                    }
                }
                Console.WriteLine("(p" + (StaticData.PageIndex + 1) + ")");
            }
            else
            {
                Console.WriteLine("没有下文了");
            }
            
        }

        string ICommand.Help()
        {
            return "u命令：向上翻页";
        }

        #endregion
    }
}
